//
//  NSDate+Formatter.swift
//  joyBao
//
//  Created by Chen on 2017/7/26.
//  Copyright © 2017年 Chen. All rights reserved.
//

import Foundation

extension Date {


    /// Date转字符串
    ///
    /// - Parameter format: 字符串格式
    /// - Returns: 对应字符串
    func format(format: String) -> String {
        let formatter = DateFormatter()
        formatter.dateFormat = format
        return formatter.string(from: self)
    }


    /// Date转时间戳
    ///
    /// - Returns: 时间戳
    func timeStamp() -> UInt64 {
        return UInt64(self.timeIntervalSince1970)
    }
    
}

